package p600;

public class Leetcode_693 {
    public boolean hasAlternatingBits(int n) {
        long l = n;
        return (l & 1) == 0
                ? allOne(( l ^ l << 1) + 1)
                : allOne(l ^ l << 1);
    }

    public boolean allOne(long n) {
        return Long.bitCount(n + 1) == 1;
    }
}
